package com.example.springdatajpa.entity;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.stereotype.Component;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 订单详情类
 */
@Entity
@Table(name = "zocai_orderdetail")
@Getter
@Setter
@Component
public class OrderDetail implements Serializable{

    @Id
    private Long id;
    @Column(name = "productId")
    private Long productId;
    @Column(name = "number")
    private Integer number;
    @Column(name = "crateDate")
    private Date crateDate;
    @Column(name = "modiftDate")
    private Date modiftDate;
    @Column(name = "price")
    private double price;
    @Column(name = "total")
    private double total;

    @Override
    public String toString() {
        return "OrderDetail{" +
                "id=" + id +
                ", productId=" + productId +
                ", number=" + number +
                ", crateDate=" + crateDate +
                ", modiftDate=" + modiftDate +
                ", price=" + price +
                ", total=" + total +
                '}';
    }

    /**
     * 多对一设置
     */
    @ManyToOne(cascade = CascadeType.PERSIST)
    @JoinColumn(name = "orderId")
    private Order order;

}
